package com.hboxs.asl.controller.asl.product;

import com.hboxs.asl.entity.Cart;
import com.hboxs.asl.service.CartService;
import com.hboxs.asl.service.ProductCategoryService;
import com.hboxs.asl.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * Controller - 商品分类
 */
@Controller("aslProductCategoryController")
@RequestMapping("/weChat/productCategory")
public class ProductCategoryController {
    @Resource(name = "productCategoryServiceImpl")
    private ProductCategoryService productCategoryService;
    @Resource(name = "productServiceImpl")
    private ProductService productService;
    @Resource(name = "cartServiceImpl")
    private CartService cartService;

    /**
     * 商品分类
     *
     * @param model
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public String list(ModelMap model) {
        Cart cart = cartService.getCurrent();
        model.addAttribute("productCategorys" , productCategoryService.findRoots());
        model.addAttribute("count", cartService.getTotalNumberOfGoodsInCart(cart));
        return "/yijing/product-category";
    }

}
